import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

# 1.创建驱动对象
service = Service("C:/Program Files/Google/Chrome/Application/chromedriver.exe")
driver = webdriver.Chrome(service=service)

# 2.打开浏览器
driver.get("file:///C:/Users/82073/Desktop/pagetest/drag.html")

# 创建鼠标执行对象
action = ActionChains(driver)
red = driver.find_element(By.CSS_SELECTOR, "#div1")
blue = driver.find_element(By.CSS_SELECTOR, "#div2")
action.drag_and_drop(red, blue).perform()

# action = ActionChains(driver)
# e = driver.find_element(By.CSS_SELECTOR, "button")
# action.move_to_element(e).perform()


# e = driver.find_element(By.CSS_SELECTOR, "#userA")
# e.send_keys("admin")
#
# time.sleep(3)
# action.double_click(e).perform()



# e = driver.find_element(By.CSS_SELECTOR, "#userA")
# # 鼠标右键
# action = ActionChains(driver)
# action.context_click(e).perform()

# 4.3s后关闭
time.sleep(3)

# 5.关闭驱动对象
driver.close()